#include "requirement_edit_dialog.h"
#include "ui_requirement_edit_dialog.h"

RequirementEditDialog::RequirementEditDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::RequirementEditDialog)
{
    ui->setupUi(this);
    initEvents();
}

RequirementEditDialog::~RequirementEditDialog()
{
    delete ui;
}

void RequirementEditDialog::setRequirementName(QString name)
{
    ui->requirementNameLineEdit->setText(name);
}

void RequirementEditDialog::setRequirementDescription(QString description)
{
    ui->requirementDescriptionTextEdit->setText(description);
}

QString RequirementEditDialog::getRequirementName()
{
    return ui->requirementNameLineEdit->text();
}

QString RequirementEditDialog::getRequirementDescription()
{
    return ui->requirementDescriptionTextEdit->toPlainText();
}

void RequirementEditDialog::initEvents()
{
    connect(ui->cancelBtn, &QPushButton::clicked, this, [=]() {
        done(QDialog::Rejected);
    });

    connect(ui->okBtn, &QPushButton::clicked, this, [=]() {
        done(QDialog::Accepted);
    });
}
